const http = require('http')

const opts = {
    host: 'www.baidu.com',
    port: 80,
    path: '/',
    method: 'GET'
}

const req = http.get(opts, res=>{
    res.on('data',data=>{
        console.log(data)
    })
})

req.on('error',err=>{
    console.log(err)
})

req.end()